package br.com.lumis.ims.service.cloud.util;

import lumis.portal.PortalException;
import lumis.portal.authentication.SessionConfig;
import lumis.util.ITransaction;
import br.com.lumis.ims.service.cloud.dao.UserDAO;
import br.com.lumis.ims.service.cloud.model.UserIMS;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;

public class ImsRequestParameters {
	public static final String ID = "id";
	public static final String NOME = "nome";
	public static final String NAME = "name";
	public static final String DESCRICAO = "descricao";
	public static final String METRICA = "metrica";
	public static final String VALOR = "valor";
	public static final String TIMESTAMP = "timestamp";
	public static final String INSTANCIAID = "instanciaId";
	public static final String DEVICE = "device";
	public static final String ACCESSKEY = "accesskey";
	public static final String SECRETKEY = "secretkey";
	//public static final String ACCESSKEY = "AKIAIPKL3QSZ6DMFGGBA";
	//public static final String SECRETKEY = "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";
	public static final String ACCESSKEYPETRO = "AKIAIZWGDMO2KJRLEAIQ";
	public static final String SECRETKEYPETRO = "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";
	public static final String DISCOID = "discoId";
	public static final String ACTIONTYPE = "actionType";
	public static final String LOGIN = "login";
	public static final String EMAIL = "email";
	public static final String PASSWORD = "password";
	public static final String CHANNEL_ID = "8A488A133755FBCF013755FCFD320251";
	public static final String USER_ADD = "addUser";
	
	
	
	
	public static AWSCredentials getCredentials(SessionConfig sessionConfig, ITransaction transaction) throws PortalException{
		UserDAO dao = new UserDAO();
		
		String userId = sessionConfig.getUserId();
		
		UserIMS ims = dao.getUserIMS(userId, transaction);
		
		if(ims !=null)
			return new BasicAWSCredentials(ims.getAccesskey(), ims.getSecretkey());
		else
			return new BasicAWSCredentials(ACCESSKEYPETRO, SECRETKEYPETRO);
	}
	
}
